home *** CD-ROM | disk | FTP | other *** search
/ Cream of the Crop 26 / Cream of the Crop 26.iso / os2 / timidsrc.zip / config.h < prev    next >
C/C++ Source or Header  |  1997-04-23  |  12KB  |  355 lines

  1. /*
  2.     TiMidity -- Experimental MIDI to WAVE converter
  3.     Copyright (C) 1995 Tuukka Toivonen <toivonen@clinet.fi>
  4.  
  5.     This program is free software; you can redistribute it and/or modify
  6.     it under the terms of the GNU General Public License as published by
  7.     the Free Software Foundation; either version 2 of the License, or
  8.     (at your option) any later version.
  9.  
  10.     This program is distributed in the hope that it will be useful,
  11.     but WITHOUT ANY WARRANTY; without even the implied warranty of
  12.     MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
  13.     GNU General Public License for more details.
  14.  
  15.     You should have received a copy of the GNU General Public License
  16.     along with this program; if not, write to the Free Software
  17.     Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
  18. */
  19.  
  20. /* Filename extension, followed by command to run decompressor so that
  21.    output is written to stdout. Terminate the list with a 0. 
  22.  
  23.    Any file with a name ending in one of these strings will be run
  24.    through the corresponding decompressor. If you don't like this
  25.    behavior, you can undefine DECOMPRESSOR_LIST to disable automatic
  26.    decompression entirely. 
  27.  
  28.    This is currently ignored for Win32. */
  29. #define DECOMPRESSOR_LIST { \
  30.                   ".gz", "gzip -cd %s", \
  31.                   ".Z", "gzip -cd %s", \
  32.                   ".zip", "unzip -p %s", \
  33.                   ".lha", "lha -pq %s", \
  34.                   ".lzh", "lha -pq %s", \
  35.                   ".shn", "shorten -x %s -", \
  36.                   ".wav", "wav2pat %s", \
  37.                  0 }
  38.  
  39. /* When a patch file can't be opened, one of these extensions is
  40.    appended to the filename and the open is tried again.
  41.  
  42.    This is ignored for Win32, which uses only ".pat" (see the bottom
  43.    of this file if you need to change this.) */
  44. #define PATCH_EXT_LIST { \
  45.                ".pat", \
  46.                ".shn", ".pat.shn", \
  47.                ".gz", ".pat.gz", \
  48.                0 }
  49.  
  50. /* Acoustic Grand Piano seems to be the usual default instrument. */
  51. #define DEFAULT_PROGRAM 0
  52.  
  53. /* 9 here is MIDI channel 10, which is the standard percussion channel.
  54.    Some files (notably C:\WINDOWS\CANYON.MID) think that 16 is one too. 
  55.    On the other hand, some files know that 16 is not a drum channel and
  56.    try to play music on it. This is now a runtime option, so this isn't
  57.    a critical choice anymore. */
  58. /*#define DEFAULT_DRUMCHANNELS (1<<9) */
  59. #define DEFAULT_DRUMCHANNELS ((1<<9) | (1<<15))
  60.  
  61. /* A somewhat arbitrary frequency range. The low end of this will
  62.    sound terrible as no lowpass filtering is performed on most
  63.    instruments before resampling. */
  64. #define MIN_OUTPUT_RATE     4000
  65. #define MAX_OUTPUT_RATE     65000
  66.  
  67. /* In percent. */
  68. #define DEFAULT_AMPLIFICATION     70
  69.  
  70. /* Default sampling rate, default polyphony, and maximum polyphony.
  71.    All but the last can be overridden from the command line. */
  72. #ifdef __EMX__
  73. #define DEFAULT_RATE    22050
  74. #else
  75. #define DEFAULT_RATE    32000
  76. #endif
  77. #define DEFAULT_VOICES    32
  78. #define MAX_VOICES    48
  79.  
  80. /* The size of the internal buffer is 2^AUDIO_BUFFER_BITS samples.
  81.    This determines maximum number of samples ever computed in a row.
  82.  
  83.    For Linux and FreeBSD users:
  84.    
  85.    This also specifies the size of the buffer fragment.  A smaller
  86.    fragment gives a faster response in interactive mode -- 10 or 11 is
  87.    probably a good number. Unfortunately some sound cards emit a click
  88.    when switching DMA buffers. If this happens to you, try increasing
  89.    this number to reduce the frequency of the clicks.
  90.  
  91.    For other systems:
  92.    
  93.    You should probably use a larger number for improved performance.
  94.  
  95. */
  96. #ifdef __WIN32__
  97. #define AUDIO_BUFFER_BITS 12
  98. #else
  99. #define AUDIO_BUFFER_BITS 11
  100. #endif
  101.  
  102. /* 1000 here will give a control ratio of 22:1 with 22 kHz output.
  103.    Higher CONTROLS_PER_SECOND values allow more accurate rendering
  104.    of envelopes and tremolo. The cost is CPU time. */
  105. #define CONTROLS_PER_SECOND 1000
  106.  
  107. /* Strongly recommended. This option increases CPU usage by half, but
  108.    without it sound quality is very poor. */
  109. #define LINEAR_INTERPOLATION
  110.  
  111. /* This is an experimental kludge that needs to be done right, but if
  112.    you've got an 8-bit sound card, or cheap multimedia speakers hooked
  113.    to your 16-bit output device, you should definitely give it a try.
  114.  
  115.    Defining LOOKUP_HACK causes table lookups to be used in mixing
  116.    instead of multiplication. We convert the sample data to 8 bits at
  117.    load time and volumes to logarithmic 7-bit values before looking up
  118.    the product, which degrades sound quality noticeably.
  119.  
  120.    Defining LOOKUP_HACK should save ~20% of CPU on an Intel machine.
  121.    LOOKUP_INTERPOLATION might give another ~5% */
  122. /* #define LOOKUP_HACK
  123.    #define LOOKUP_INTERPOLATION */
  124.  
  125. /* Make envelopes twice as fast. Saves ~20% CPU time (notes decay
  126.    faster) and sounds more like a GUS. There is now a command line
  127.    option to toggle this as well. */
  128. #define FAST_DECAY
  129.  
  130. /* How many bits to use for the fractional part of sample positions.
  131.    This affects tonal accuracy. The entire position counter must fit
  132.    in 32 bits, so with FRACTION_BITS equal to 12, the maximum size of
  133.    a sample is 1048576 samples (2 megabytes in memory). The GUS gets
  134.    by with just 9 bits and a little help from its friends...
  135.    "The GUS does not SUCK!!!" -- a happy user :) */
  136. #define FRACTION_BITS 12
  137.  
  138. /* For some reason the sample volume is always set to maximum in all
  139.    patch files. Define this for a crude adjustment that may help
  140.    equalize instrument volumes. */
  141. #define ADJUST_SAMPLE_VOLUMES
  142.  
  143. /* If you have root access, you can define DANGEROUS_RENICE and chmod
  144.    timidity setuid root to have it automatically raise its priority
  145.    when run -- this may make it possible to play MIDI files in the
  146.    background while running other CPU-intensive jobs. Of course no
  147.    amount of renicing will help if the CPU time simply isn't there.
  148.  
  149.    The root privileges are used and dropped at the beginning of main()
  150.    in timidity.c -- please check the code to your satisfaction before
  151.    using this option. (And please check sections 11 and 12 in the
  152.    GNU General Public License (under GNU Emacs, hit ^H^W) ;) */
  153. /* #define DANGEROUS_RENICE -15 */
  154.  
  155. /* The number of samples to use for ramping out a dying note. Affects
  156.    click removal. */
  157. #define MAX_DIE_TIME 20
  158.  
  159. /* On some machines (especially PCs without math coprocessors),
  160.    looking up sine values in a table will be significantly faster than
  161.    computing them on the fly. Uncomment this to use lookups. */
  162. /* #define LOOKUP_SINE */
  163.  
  164. /* Shawn McHorse's resampling optimizations. These may not in fact be
  165.    faster on your particular machine and compiler. You'll have to run
  166.    a benchmark to find out. */
  167. #define PRECALC_LOOPS
  168.  
  169. /* If calling ldexp() is faster than a floating point multiplication
  170.    on your machine/compiler/libm, uncomment this. It doesn't make much
  171.    difference either way, but hey -- it was on the TODO list, so it
  172.    got done. */
  173. /* #define USE_LDEXP */
  174.  
  175. /**************************************************************************/
  176. /* Anything below this shouldn't need to be changed unless you're porting
  177.    to a new machine with other than 32-bit, big-endian words. */
  178. /**************************************************************************/
  179.  
  180. /* change FRACTION_BITS above, not these */
  181. #define INTEGER_BITS (32 - FRACTION_BITS)
  182. #define INTEGER_MASK (0xFFFFFFFF << FRACTION_BITS)
  183. #define FRACTION_MASK (~ INTEGER_MASK)
  184.  
  185. /* This is enforced by some computations that must fit in an int */
  186. #define MAX_CONTROL_RATIO 255
  187.  
  188. /* Audio buffer size has to be a power of two to allow DMA buffer
  189.    fragments under the VoxWare (Linux & FreeBSD) audio driver */
  190. #define AUDIO_BUFFER_SIZE (1<<AUDIO_BUFFER_BITS)
  191.  
  192. /* Byte order, defined in <machine/endian.h> for FreeBSD and DEC OSF/1 */
  193. #ifdef DEC
  194. #include <machine/endian.h>
  195. #endif
  196.  
  197. #if defined(linux) || defined(__EMX__)
  198. /*
  199.  * Byte order is defined in <bytesex.h> as __BYTE_ORDER, that need to
  200.  * be checked against __LITTLE_ENDIAN and __BIG_ENDIAN defined in <endian.h>
  201.  * <endian.h> includes automagically <bytesex.h>
  202.  * for Linux.
  203.  */
  204. #ifdef __EMX__
  205. #include <386/endian.h>
  206. #endif
  207.  
  208. /*
  209.  * We undef the two things to start with a clean situation
  210.  * (oddly enough, <endian.h> defines under certain conditions
  211.  * the two things below, as __LITTLE_ENDIAN and __BIG_ENDIAN, that
  212.  * are useless for our plans)
  213.  */
  214. #undef LITTLE_ENDIAN
  215. #undef BIG_ENDIAN
  216.  
  217. # if __BYTE_ORDER == __LITTLE_ENDIAN
  218. #  define LITTLE_ENDIAN
  219. # elif __BYTE_ORDER == __BIG_ENDIAN
  220. #  define BIG_ENDIAN
  221. # else
  222. # error No byte sex defined
  223. # endif
  224. #endif /* linux */
  225.  
  226. /* Win32 on Intel machines */
  227. #ifdef __WIN32__
  228. #  define LITTLE_ENDIAN
  229. #endif
  230.  
  231. /* DEC MMS has 64 bit long words */
  232. #ifdef DEC
  233. typedef unsigned int uint32;
  234. typedef int int32; 
  235. #else
  236. typedef unsigned long uint32;
  237. typedef long int32; 
  238. #endif
  239. typedef unsigned short uint16;
  240. typedef short int16;
  241. typedef unsigned char uint8;
  242. typedef char int8;
  243.  
  244. /* Instrument files are little-endian, MIDI files big-endian, so we
  245.    need to do some conversions. */
  246.  
  247. #define XCHG_SHORT(x) ((((x)&0xFF)<<8) | (((x)>>8)&0xFF))
  248. #ifdef __i486__
  249. # define XCHG_LONG(x) \
  250.      ({ int32 __value; \
  251.         asm ("bswap %1; movl %1,%0" : "=g" (__value) : "r" (x)); \
  252.        __value; })
  253. #else
  254. # define XCHG_LONG(x) ((((x)&0xFF)<<24) | \
  255.               (((x)&0xFF00)<<8) | \
  256.               (((x)&0xFF0000)>>8) | \
  257.               (((x)>>24)&0xFF))
  258. #endif
  259.  
  260. #ifdef LITTLE_ENDIAN
  261. #define LE_SHORT(x) x
  262. #define LE_LONG(x) x
  263. #define BE_SHORT(x) XCHG_SHORT(x)
  264. #define BE_LONG(x) XCHG_LONG(x)
  265. #else
  266. #define BE_SHORT(x) x
  267. #define BE_LONG(x) x
  268. #define LE_SHORT(x) XCHG_SHORT(x)
  269. #define LE_LONG(x) XCHG_LONG(x)
  270. #endif
  271.  
  272. #define MAX_AMPLIFICATION 800
  273.  
  274. /* You could specify a complete path, e.g. "/etc/timidity.cfg", and
  275.    then specify the library directory in the configuration file. */
  276. #define CONFIG_FILE    "timidity.cfg"
  277.  
  278. /* These affect general volume */
  279. #define GUARD_BITS 3
  280. #define AMP_BITS (15-GUARD_BITS)
  281.  
  282. #ifdef LOOKUP_HACK
  283.    typedef int8 sample_t;
  284.    typedef uint8 final_volume_t;
  285. #  define FINAL_VOLUME(v) (~_l2u[v])
  286. #  define MIXUP_SHIFT 5
  287. #  define MAX_AMP_VALUE 4095
  288. #else
  289.    typedef int16 sample_t;
  290.    typedef int32 final_volume_t;
  291. #  define FINAL_VOLUME(v) (v)
  292. #  define MAX_AMP_VALUE ((1<<(AMP_BITS+1))-1)
  293. #endif
  294.  
  295. #ifdef USE_LDEXP
  296. #  define FSCALE(a,b) ldexp((a),(b))
  297. #  define FSCALENEG(a,b) ldexp((a),-(b))
  298. #else
  299. #  define FSCALE(a,b) ((a) * (double)(1<<(b)))
  300. #  define FSCALENEG(a,b) ((a) * (1.0L / (double)(1<<(b))))
  301. #endif
  302.  
  303. /* Vibrato and tremolo Choices of the Day */
  304. #define SWEEP_TUNING 38
  305. #define VIBRATO_AMPLITUDE_TUNING 1.0L
  306. #define VIBRATO_RATE_TUNING 38
  307. #define TREMOLO_AMPLITUDE_TUNING 1.0L
  308. #define TREMOLO_RATE_TUNING 38
  309.  
  310. #define SWEEP_SHIFT 16
  311. #define RATE_SHIFT 5
  312.  
  313. #define VIBRATO_SAMPLE_INCREMENTS 32
  314.  
  315. #ifdef HPUX
  316.   extern char *sys_errlist[];
  317.   #define PI 3.14159265358979323846
  318. #endif
  319.  
  320. #ifdef SUN
  321.   #ifndef SOLARIS
  322.     #include <sys/stdtypes.h>
  323.   #endif
  324.   #include <errno.h>
  325.   extern char *sys_errlist[];
  326.   extern int opterr;
  327.   extern int optind;
  328.   extern int optopt;
  329.   extern char *optarg;
  330.   #define PI 3.14159265358979323846
  331.   #define rindex(s,c) strrchr(s,c)
  332. #endif
  333.  
  334. #ifdef __WIN32__
  335. #  include <math.h>
  336. #  define PI M_PI
  337. #  undef DECOMPRESSOR_LIST
  338. #  undef PATCH_EXT_LIST
  339. #  define PATCH_EXT_LIST { ".pat", 0 }
  340. #endif
  341.  
  342. /* The path separator (D.M.) */
  343. #ifdef __WIN32__
  344. #  define PATH_SEP '\\'
  345. #  define PATH_STRING "\\"
  346. #else
  347. #  define PATH_SEP '/'
  348. #  define PATH_STRING "/"
  349. #endif
  350.  
  351. #ifdef DEC
  352.   #include <errno.h>
  353.   #define PI 3.14159265358979323846
  354. #endif
  355.